<html>
<head><meta charset="utf-8"><title>mem::zeroed guarantees that all bytes are zero · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html">mem::zeroed guarantees that all bytes are zero</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="172127416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172127416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172127416">(Jul 31 2019 at 13:32)</a>:</h4>
<p>I think the API docs of <code>mem::zeroed</code> are incorrect. They currently say: </p>
<blockquote>
<p>Creates a value whose bytes are all zero.</p>
</blockquote>



<a name="172127466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172127466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172127466">(Jul 31 2019 at 13:33)</a>:</h4>
<p>From which it follows that:</p>



<a name="172127557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172127557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172127557">(Jul 31 2019 at 13:34)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="cp">#[repr(C)]</span><span class="w"> </span><span class="p">(</span><span class="kt">u8</span><span class="p">,</span><span class="w"> </span><span class="kt">u16</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">zeroed</span><span class="p">();</span><span class="w"></span>
<span class="n">assert_eq</span><span class="o">!</span><span class="p">((</span><span class="o">&amp;</span><span class="n">x</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="o">*</span><span class="k">const</span><span class="w"> </span><span class="kt">u8</span><span class="p">).</span><span class="n">add</span><span class="p">(</span><span class="mi">1</span><span class="p">).</span><span class="n">read</span><span class="p">(),</span><span class="w"> </span><span class="mi">0</span><span class="p">);</span><span class="w"> </span><span class="c1">// always passes</span>
</pre></div>



<a name="172127599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172127599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172127599">(Jul 31 2019 at 13:35)</a>:</h4>
<p>I don't think we can guarantee anywhere which values <code>mem::zeroed()</code> writes to padding bytes, and it probably should write anything to them</p>



<a name="172127607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172127607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172127607">(Jul 31 2019 at 13:35)</a>:</h4>
<p>definetely not be required / guarantee that it does</p>



<a name="172130797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172130797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172130797">(Jul 31 2019 at 14:12)</a>:</h4>
<p>Yeah. Please file an issue.</p>



<a name="172145711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172145711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172145711">(Jul 31 2019 at 17:16)</a>:</h4>
<p>I see. In my view what happens is that indeed there was an all-0 value, but then when the function returns that value, "typed copy" rules apply.</p>



<a name="172145739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172145739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172145739">(Jul 31 2019 at 17:16)</a>:</h4>
<p>This expalains both why there is UB if 0 does not satisfy the validity invariant, and why padding is not preserved.</p>



<a name="172147992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172147992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172147992">(Jul 31 2019 at 17:43)</a>:</h4>
<p>That is technically correct but we should definitely note explicitly what happens with padding, because it's subtle</p>



<a name="172149887"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172149887" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172149887">(Jul 31 2019 at 18:01)</a>:</h4>
<p>indeed, the docs don't need to talk about "typed copies" or so.</p>



<a name="172149931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172149931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172149931">(Jul 31 2019 at 18:01)</a>:</h4>
<p>I was thinking of the abstract machine spec and making sure it doesnt have to account separately for the padding here.</p>



<a name="172149942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172149942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172149942">(Jul 31 2019 at 18:01)</a>:</h4>
<p>And I was also thinking of the abstract machine when writing those docs, which is why I missed the padding aspect. ;)</p>



<a name="172150500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172150500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172150500">(Jul 31 2019 at 18:06)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> <span class="user-mention" data-user-id="124289">@rkruppe</span> so just to triple check. IIUC even with the current API docs, the assert here can fail right ?</p>
<div class="codehilite"><pre><span></span><span class="k">union</span> <span class="nc">U</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">x</span>: <span class="nc">T</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">y</span>: <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">U</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="nc">std</span>::<span class="n">mem</span>::<span class="n">zeroed</span><span class="p">()</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">u</span><span class="p">.</span><span class="n">y</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="mi">0_</span><span class="k">u8</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">]);</span><span class="w"></span>
</pre></div>



<a name="172150604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172150604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172150604">(Jul 31 2019 at 18:07)</a>:</h4>
<p>(supposing that all zeroes is a valid representation for T, etc.</p>



<a name="172150719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172150719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172150719">(Jul 31 2019 at 18:08)</a>:</h4>
<p>Yes. Arguably it might even be UB, if we say padding is always written as 0xUU</p>



<a name="172150990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172150990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172150990">(Jul 31 2019 at 18:11)</a>:</h4>
<p>Well I suppose the question is whether this code is UB or not then.</p>



<a name="172151173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172151173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172151173">(Jul 31 2019 at 18:12)</a>:</h4>
<p>I think that even with the current docs that say that it writes zero to all bytes of T, the behavior is undefined, because the value of the padding bytes can change to undef before the read of y</p>



<a name="172151316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172151316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172151316">(Jul 31 2019 at 18:14)</a>:</h4>
<p>Oh wait, what do you mean by "even with the current API docs"?</p>



<a name="172152607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172152607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172152607">(Jul 31 2019 at 18:27)</a>:</h4>
<p>The current docs guarantee that all bytes of T are actually zeroed</p>



<a name="172154612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172154612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172154612">(Jul 31 2019 at 18:48)</a>:</h4>
<p>I guess my confusion is whether you mean what a normal user would intuit or what follows from the "typed copy" perspective</p>



<a name="172158084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172158084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172158084">(Jul 31 2019 at 19:33)</a>:</h4>
<blockquote>
<p>I think that even with the current docs that say that it writes zero to all bytes of T, the behavior is undefined, because the value of the padding bytes can change to undef before the read of y</p>
</blockquote>
<p>that depends on whether there was ever a type at type <code>T</code></p>



<a name="172158113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172158113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172158113">(Jul 31 2019 at 19:33)</a>:</h4>
<p>as <span class="user-mention" data-user-id="124289">@rkruppe</span> argued on GH, there is no such thing as a "padding byte" per se. There is only a "padding byte for some type <code>T</code>".</p>



<a name="172158252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172158252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172158252">(Jul 31 2019 at 19:35)</a>:</h4>
<p>evaluating zeroed() and putting the result in the union is uncontroversially a typed copy, right?</p>



<a name="172158549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172158549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172158549">(Jul 31 2019 at 19:38)</a>:</h4>
<p>yes. but <span class="user-mention" data-user-id="132920">@gnzlbg</span> was hypothesizing "with the current docs".</p>



<a name="172158561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172158561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172158561">(Jul 31 2019 at 19:38)</a>:</h4>
<p>I guess that's a moot point because the current docs are not operational enough to answer this question.</p>



<a name="172198131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172198131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172198131">(Aug 01 2019 at 07:29)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> They might be barely enough. For example, is this a valid transformation of the program above?</p>
<div class="codehilite"><pre><span></span><span class="k">union</span> <span class="nc">U</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">x</span>: <span class="nc">T</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">y</span>: <span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">std</span>::<span class="n">mem</span>::<span class="n">size_of</span>::<span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()]</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">tmp</span>: <span class="nc">T</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span>: <span class="nc">std</span>::<span class="n">mem</span>::<span class="n">zeroed</span><span class="p">();</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">u</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">U</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">x</span>: <span class="nc">tmp</span><span class="w"> </span><span class="p">};</span><span class="w"></span>
<span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="n">u</span><span class="p">.</span><span class="n">y</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="mi">0_</span><span class="k">u8</span><span class="p">;</span><span class="w"> </span><span class="mi">4</span><span class="p">]);</span><span class="w"></span>
</pre></div>



<a name="172198161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172198161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172198161">(Aug 01 2019 at 07:29)</a>:</h4>
<p>I think so,  so even with the current docs, we do not guarantee that the assert will pass. The behavior of the assert is undefined.</p>



<a name="172198165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172198165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172198165">(Aug 01 2019 at 07:30)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> I think we both agree on what the semantics of <code>zeroed</code> are, don't we? and that the docs can be improved?</p>



<a name="172198224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172198224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172198224">(Aug 01 2019 at 07:30)</a>:</h4>
<p>I see no point in trying to interpret more into these docs <em>that I wrote</em> than I had in my mind when writing them^^</p>



<a name="172198243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172198243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172198243">(Aug 01 2019 at 07:30)</a>:</h4>
<p>"can and should be improved", that is</p>



<a name="172198962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172198962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172198962">(Aug 01 2019 at 07:42)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> shall I fill an issue ? or shall we try to come up with wording that fixes them and just modify them ?</p>



<a name="172198970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172198970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172198970">(Aug 01 2019 at 07:42)</a>:</h4>
<p>I think that saying that it zeroes the bytes "of the value representation of <code>T</code>" should be enough</p>



<a name="172199565"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172199565" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172199565">(Aug 01 2019 at 07:52)</a>:</h4>
<p>except nobody will understand what that means</p>



<a name="172199579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172199579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172199579">(Aug 01 2019 at 07:52)</a>:</h4>
<p>like, not even in the UCG glossary with all my PRs merged have we defined "the bytes of the value representation of <code>T</code>"</p>



<a name="172199658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172199658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172199658">(Aug 01 2019 at 07:54)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> alternative proposal: something along the lines of "transmutes zero-ed memory to <code>T</code>". and then we can go on explaining that, since padding bytes are not preserved when e.g. returned from a function, this means that some bytes of the returned datum can be 0.</p>



<a name="172199728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172199728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172199728">(Aug 01 2019 at 07:54)</a>:</h4>
<p>yet another proposal: actually functions return values, not lists of bytes or so, so the "return value" doesn't even have padding. so we could try something along the lines of "returns the value represented by the all-0 bit pattern".</p>



<a name="172200129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172200129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172200129">(Aug 01 2019 at 08:01)</a>:</h4>
<p>These two are very clever but I don't think there is any wording that avoids the need for an explicit note to the effect that padding is not preserved in this case either, and so if <code>T</code> has padding, the result will not be entirely zeroes. We don't don't need a precise official definition of padding (and when it is lost) or go into the differences between values and bytes lists to say that.</p>



<a name="172200606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172200606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172200606">(Aug 01 2019 at 08:08)</a>:</h4>
<p>sure, I am all for explicitly stating the consequences of the definition. but at the same time I dont want this to sound like a weird magic special case, which it is not.</p>



<a name="172200627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172200627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172200627">(Aug 01 2019 at 08:09)</a>:</h4>
<p>The actual wording with such a note might even be enough?</p>



<a name="172200651"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172200651" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172200651">(Aug 01 2019 at 08:09)</a>:</h4>
<p>Otherwise, saying that "<code>mem::zeroed&lt;T&gt;</code> returns the value represented by the all-0 bit pattern" seems good as well.</p>



<a name="172202768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172202768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172202768">(Aug 01 2019 at 08:47)</a>:</h4>
<p>I like "the value represented by the all-0 bit pattern" because it does not involve a lot of weird jargon -- the terms there have a precise meaning but you can also read it and kind of understand it without knowing that precise meanings.<br>
but we should definitely add a note saying that this means e.g. for <code>(u8, u16)</code> the padding byte does <em>not</em> have to be 0.</p>



<a name="172204033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172204033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172204033">(Aug 01 2019 at 09:08)</a>:</h4>
<p>Sounds good to me.</p>



<a name="172204799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172204799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172204799">(Aug 01 2019 at 09:20)</a>:</h4>
<p>do you want to make a PR?</p>



<a name="172204956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172204956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172204956">(Aug 01 2019 at 09:23)</a>:</h4>
<p>i could at some point, but every time I need to make a PR, I need to branch, branches get out of sync, switching between branches takes days if LLVM needs to be recompiled, etc.</p>



<a name="172205085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172205085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172205085">(Aug 01 2019 at 09:25)</a>:</h4>
<p>having multiple checkouts helps</p>



<a name="172205147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172205147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172205147">(Aug 01 2019 at 09:26)</a>:</h4>
<p>so you can have multiple branches checked out and built (I use <code>git worktree</code> for that)</p>



<a name="172205159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172205159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172205159">(Aug 01 2019 at 09:26)</a>:</h4>
<p>of course it also means <em>when</em> LLVM updates it needs to eventually be recompiled once for each worktree^^</p>



<a name="172205182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172205182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172205182">(Aug 01 2019 at 09:27)</a>:</h4>
<p>but for this PR you dont even need LLVM</p>



<a name="172205189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172205189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172205189">(Aug 01 2019 at 09:27)</a>:</h4>
<p><code>./x.py test --stage 0 src/libcore</code> should be all you need</p>



<a name="172205204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172205204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172205204">(Aug 01 2019 at 09:27)</a>:</h4>
<p>that takes just a few min even on a fresh checkout</p>



<a name="172207130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172207130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172207130">(Aug 01 2019 at 09:58)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> each check out takes ~30 Gb</p>



<a name="172207148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172207148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172207148">(Aug 01 2019 at 09:58)</a>:</h4>
<p>my laptop has ~256 Gb and is quite full, so I'm bottle necked at one checkout</p>



<a name="172208599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172208599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172208599">(Aug 01 2019 at 10:23)</a>:</h4>
<p>ah. yeah Rust eats disk space like there's no tomorrow.</p>



<a name="172208603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172208603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172208603">(Aug 01 2019 at 10:23)</a>:</h4>
<p>I recently freed 100GB by cleaning my compiler checkouts and a few projects.</p>



<a name="172213801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172213801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172213801">(Aug 01 2019 at 11:57)</a>:</h4>
<p>I need to start using the GCC compile farm again</p>



<a name="172261955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172261955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172261955">(Aug 01 2019 at 21:11)</a>:</h4>
<p><span class="user-mention" data-user-id="132920">@gnzlbg</span> you don't even need to do anything locally; just make a branch via the github UI and edit the text there...</p>



<a name="172732304"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172732304" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172732304">(Aug 08 2019 at 02:15)</a>:</h4>
<p>yeah for just a docs change the webpage works great.</p>



<a name="172746810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172746810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172746810">(Aug 08 2019 at 08:15)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> what were you respond to? The docs change <a href="https://doc.rust-lang.org/nightly/std/mem/fn.zeroed.html" target="_blank" title="https://doc.rust-lang.org/nightly/std/mem/fn.zeroed.html">has already landed</a>. Which webpage?</p>



<a name="172747408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172747408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172747408">(Aug 08 2019 at 08:26)</a>:</h4>
<p>Sorry, I hadn't noticed the date on the thread. I was agreeing with Centril that just editing docs through the github webpage is much easier than cloning a local copy of rustc</p>



<a name="172747540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem%3A%3Azeroed%20guarantees%20that%20all%20bytes%20are%20zero/near/172747540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/mem.3A.3Azeroed.20guarantees.20that.20all.20bytes.20are.20zero.html#172747540">(Aug 08 2019 at 08:29)</a>:</h4>
<p>dunno, I am usually doing this in one of the 3 local copies I have and I prefer having a proper editor ;)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>